<template>
  <div class="homepage" @scroll="handleScroll">
    <!-- 导航栏 -->
    <header class="navbar" :class="{ 'scrolled': isScrolled }">
      <div class="container">
        <div class="logo">自动化平台</div>
        <nav class="nav-links">
          <a href="#features">功能</a>
          <a href="#products">产品</a>
          <a href="#contact">联系我们</a>
          <button class="login-btn" @click="$router.push('/login')">登录</button>
        </nav>
      </div>
    </header>

    <!-- 英雄区域 -->
    <section class="hero">
      <div class="container">
        <div class="hero-content">
          <h1>智能自动化平台</h1>
          <p>提升效率，减少人工操作，实现全流程自动化</p>
          <button class="get-started-btn">立即开始</button>
        </div>
      </div>
    </section>

    <!-- 功能介绍 -->
    <section id="features" class="features">
      <div class="container">
        <h2>核心功能</h2>
        <div class="features-grid">
          <div class="feature-card">
            <h3>任务自动化</h3>
            <p>一键配置，自动执行重复性任务</p>
          </div>
          <div class="feature-card">
            <h3>智能监控</h3>
            <p>实时监控系统状态，及时发现问题</p>
          </div>
          <div class="feature-card">
            <h3>数据分析</h3>
            <p>生成详细报告，助力决策优化</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 页脚 -->
    <footer class="footer">
      <p>© 2023 自动化平台 版权所有</p>
    </footer>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';

const isScrolled = ref(false);

// 处理滚动事件，用于导航栏样式变化
const handleScroll = () => {
  isScrolled.value = window.scrollY > 50;
};

// 页面加载时检查滚动位置
onMounted(() => {
  handleScroll();
  window.addEventListener('scroll', handleScroll);
});
</script>

<style scoped>
/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
  scroll-behavior: smooth;
  /* 平滑滚动 */
}

.homepage {
  width: 100vw;
}

/* 容器样式 */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* 导航栏 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  width: 100%;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.navbar.scrolled {
  padding: 0.8rem 5%;
  background-color: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(5px);
}

/* 响应式调整 - 大屏幕优化 */
@media (min-width: 1024px) {
  .hero-content h1 {
    font-size: 3.5rem;
  }
}

@media (min-width: 1440px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-content h1 {
    font-size: 4.5rem;
  }

  .feature-card {
    padding: 3rem;
  }
}

/* 焦点状态优化 */
.login-btn:focus,
.get-started-btn:focus {
  outline: 3px solid rgba(0, 123, 255, 0.3);
  outline-offset: 2px;
}

/* 平滑动画 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.features-grid {
  animation: fadeInUp 0.8s ease-out;
}

.logo {
  font-size: 2rem;
  font-weight: bold;
  color: #333333;
}

.nav-links {
  display: flex;
  gap: 2rem;
  font-size: 1.5rem;
}

.nav-links a {
  text-decoration: none;
  color: #666666;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: #007bff;
}

.login-btn {
  padding: 0.5rem 1rem;
  border: none;
  background-color: #007bff;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.login-btn:hover {
  background-color: #0056b3;
}

/* 英雄区域 */
.hero {
  height: 100vh;
  min-height: 600px;
  background: linear-gradient(135deg, #007bff 0%, #00a8ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  padding: 0 5%;
  margin-top: 85px;
  /* 增加顶部边距避免导航栏遮挡 */
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
}

.hero-content h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 1.5rem;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.hero-content p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

.get-started-btn {
  padding: 1rem 2rem;
  font-size: 1rem;
  border: none;
  background-color: white;
  color: #007bff;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.3s;
}

.get-started-btn:hover {
  transform: scale(1.05);
}

/* 功能介绍 */
.features {
  padding: 8rem 5%;
  text-align: center;
  background-color: #f9fafb;
}

.features h2 {
  font-size: 2rem;
  margin-bottom: 3rem;
  color: #333333;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3rem;
  margin-top: 5rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.feature-card {
  padding: 2.5rem;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #333333;
}

.feature-card p {
  color: #666666;
}

/* 页脚 */
.footer {
  padding: 2rem 5%;
  background-color: #333333;
  color: white;
  text-align: center;
}
</style>